package com.caojing.syby.ui.tenbuy.tenbuysharefragment;

import android.os.Handler;
import android.os.Looper;

import com.caojing.syby.bean.home.RowsBean;
import com.caojing.syby.bean.tenbuy.ShareGvBean;


import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Administrator on 2016/10/6 0006.
 */
public class TenbuySharePresenter implements TenbuyShareConstrct.Presenter{
    private TenbuyShareConstrct.View view;
    private TenbuyShareConstrct.Modle modle;

    public TenbuySharePresenter(TenbuyShareConstrct.View view){
        this.view=view;
        this.modle=new TenbuyShareModle();
    }



    @Override
    public void getVertical(Map<String, String> params) {
        modle.getVertical(params, new Callback<ShareGvBean>() {
            @Override
            public void onResponse(Call<ShareGvBean> call, Response<ShareGvBean> response) {
                ShareGvBean shareGvBean = response.body();
                final List<RowsBean> rows = shareGvBean.getRows();
                Handler handler=new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                       view.onGetVerticalSucess(rows);
                    }
                });


            }

            @Override
            public void onFailure(Call<ShareGvBean> call, Throwable t) {
               Handler handler=new Handler((Looper.getMainLooper()));
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onGetVerticalFail("网络连接失败");
                    }
                });
            }
        });

    }
}
